# Maintainer: Rafał Brzegowy <rafal.brzegowy@yahoo.com>

_realname=starpu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.7
pkgrel=1
pkgdesc='StarPU is a task programming library for hybrid architectures (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://starpu.gitlabpages.inria.fr'
msys2_repository_url="https://gitlab.inria.fr/starpu/starpu"
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-glpk"
         "${MINGW_PACKAGE_PREFIX}-hdf5"
         "${MINGW_PACKAGE_PREFIX}-hwloc"
         $([[ ${CARCH} == aarch64 ]] || echo "${MINGW_PACKAGE_PREFIX}-leveldb")
         "${MINGW_PACKAGE_PREFIX}-libwinpthread-git"
         #"${MINGW_PACKAGE_PREFIX}-openblas"
         "${MINGW_PACKAGE_PREFIX}-opencl-icd"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-opencl-headers"
  #"${MINGW_PACKAGE_PREFIX}-python"
  #"${MINGW_PACKAGE_PREFIX}-python-setuptools"
  #"${MINGW_PACKAGE_PREFIX}-python-joblib"
  #"${MINGW_PACKAGE_PREFIX}-python-cloudpickle"
  #"${MINGW_PACKAGE_PREFIX}-python-numpy"
)
options=('!docs')
source=(https://files.inria.fr/starpu/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('1eb3df551089153fe6e0b172ad95118434b4a81ea9eaa5a2c38725d0db53b13e')

prepare() {
  cd ${_realname}-${pkgver}
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  declare -a _extra_config
  if [[ ${CARCH} != aarch64 ]]; then
    _extra_config+=("--enable-leveldb")
  fi

  CFLAGS+=" -Wno-null-dereference" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-hdf5 \
    --enable-maxcpus=64 \
    --enable-opencl \
    --enable-quick-check \
    --enable-socl \
    --disable-build-doc \
    --disable-build-examples \
    --disable-fortran \
    --disable-gdb \
    --disable-mpi \
    --disable-starpupy \
    "${_extra_config[@]}"

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING.LGPL "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
